/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 有点呆
 * Date: 2024-11-14
 * Time: 12:05
 */

public class Area {

    private int id;//分区号
    private int size;//分区大小
    private int startAddress;//分区开始地址
    //状态=（空闲、忙、碎片（2K））
    //1表示空闲、2表示忙、0表示碎片
    private int state;
    //判断进程与内存分区是否合适
    public boolean commpare(int size) {
        if(size<=this.size){
            return true;
        }else {
            return false;
        }
    }
    //划出合适的内存
    public void drawOut(int size) {
        this.size-=size;
        this.startAddress+=size;
        if(this.size<=2) {
            this.state=0;//碎片
        }
    }
    //回收方法
    public void recovery(int size,int n) {

    }

    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public int getSize() {
        return size;
    }
    public void setSize(int size) {
        this.size = size;
    }
    public int getStartAddress() {
        return startAddress;
    }
    public void setStartAddress(int startAddress) {
        this.startAddress = startAddress;
    }
    public int getState() {
        return state;
    }
    public void setState(int state) {
        this.state = state;
    }
    public Area(int id, int size, int startAddress, int state) {
        super();
        this.id = id;
        this.size = size;
        this.startAddress = startAddress;
        this.state = state;
    }
    @Override
    public String toString() {
        return "Area [id=" + id + ", size=" + size + ", startAddress=" + startAddress + ", state=" + state + "]\r\n";
    }

}